<?php
/**
 * Created by PhpStorm.
 * User: u
 * Date: 2019/4/8
 * Time: 14:59
 */

namespace common\sources\read\peppercash;




use common\models\craftsman\BuyPepperRecord;
use common\models\craftsman\PepperCashRecord;

class PepperCashAccess implements IPepperCashAccess
{
    public function getCount($data)
    {
        return PepperCashRecord::find()
                ->where(['buy_id' => $data['buy_id']])
                ->count();
    }

    public function getList($data)
     {
         return PepperCashRecord::find()
                ->select("id,cash_num,money,status,remark,cash_money,reason,create_time")
                ->where(['buy_id' => $data['buy_id']])
                ->orderBy("id desc")
                ->offset(($data['page_num'] -1)* $data['limit'])
                ->limit($data['limit'])
                ->asArray()
                ->all();
     }

     public function getPepperCashById($pepper_cash_id)
     {
         return PepperCashRecord::find()
             ->select("id,cash_num,money,status,remark,create_time")
             ->where(['id' => $pepper_cash_id])
             ->asArray()
             ->one();
     }
}